import { Injectable } from '@angular/core';
import { RequestClass } from './request.service';
@Injectable()
export class PostService{
    constructor(private requestclass: RequestClass) {}
    fetchPostList = async () => {
        return await this.requestclass.request.Pget('/role/getinfos')
      }
      
     addPost = async ({ name, desc }) => {
        return await this.requestclass.request.Ppost('/role/insertrole', {
          data: {
            roleName: name,
            description: desc,
          },
        })
      }
      
      editPostByConfig = async ({ roleId, roleName, description }) => {
        return await this.requestclass.request.Pput('/role/updaterole', {
          data: {
            roleId,
            roleName,
            description,
          },
        })
      }
      
      deletePost = async ({ id }) => {
        return await this.requestclass.request.Pdelete('/role/deleterole', {
          params: {
            idList: id,
          },
        })
      }
      
      fetchGlobalAuthority = async () => {
        return await this.requestclass.request.Pget('/global/funcs')
      }
      fetchAccountsListById = async ({ id }) => {
        return await this.requestclass.request.Pget('/role/roleUser/' + id)
      }
      
      fetchPostById = async ({ id }) => {
        return await this.requestclass.request.Pget('/role/getinfo/' + id)
      }
      
      saveAccount2PostByList = async ({ id, list }) => {
        return await this.requestclass.request.post('/role/roleUser/set', {
          params: {
            roleId: id,
          },
          // data: {
          //   sysRoleAndPermissionVos: list,
          // },
          data: list,
        })
      }
      
      
}